package com.angis.fx.handler;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.angis.fx.data.CKTypeInfo;
import com.angis.fx.db.WGTypeDBHelper;

public class WGTypeDBHandler {

	public static List<CKTypeInfo> getAllWGTypeData(Context pContext) {
		WGTypeDBHelper lDBHelper = new WGTypeDBHelper(pContext);
		Cursor lCursor = lDBHelper.getAllWGTypeUseDistinct();
		List<CKTypeInfo> lCKTypeInfoList = null;
		if(lCursor.moveToFirst()) {
			lCKTypeInfoList = new ArrayList<CKTypeInfo>();
			do {
				CKTypeInfo lCKTypeInfo = new CKTypeInfo();
				lCKTypeInfo.setConditionType(lCursor.getString(1));
				lCKTypeInfoList.add(lCKTypeInfo);
			} while (lCursor.moveToNext());
		}
		lCursor.close();
		lDBHelper.closeDB();
		return lCKTypeInfoList;
	}
	
	public static List<CKTypeInfo> getAllWGTypeByConditionType(Context pContext, String pConditionType) {
		List<CKTypeInfo> lCKTypeInfoList = null;
		lCKTypeInfoList = new ArrayList<CKTypeInfo>();
		WGTypeDBHelper lDBHelper = new WGTypeDBHelper(pContext);
		Cursor lCursor = lDBHelper.getWGTypeByConditionType(pConditionType);
		if(lCursor.moveToFirst()) {
			do {
				CKTypeInfo lCKTypeInfo = new CKTypeInfo();
				lCKTypeInfo.setWid(lCursor.getString(0));
				lCKTypeInfo.setConditionType(lCursor.getString(1));
				lCKTypeInfo.setWgType(lCursor.getString(2));
				lCKTypeInfo.setCreationTime(lCursor.getString(3));
				lCKTypeInfoList.add(lCKTypeInfo);
			} while (lCursor.moveToNext());
		}
		lCursor.close();
		lDBHelper.closeDB();
		return lCKTypeInfoList;
	}
	
}
